<template>
  <div id="personalHomePage">
    <!-- 头部大背景div -->
    <div class="bigBackground">
      <!-- 返回按钮 -->
      <div class="w1190 wrap">
        <div class="backbtn dis-flex f-y-center f-x-center" @click="goBack">
          <img
            class="dir_img"
            src="@/assets/images/personalCenter/dir.png"
            alt=""
          />
          <div class="btn_txt">返回</div>
        </div>
      </div>
    </div>

    <!-- 用户头像部分 -->
    <div class="userInfo">
      <img
        :src="
          userInfo.avatar
            ? userInfo.avatar
            : require('@/assets/images/mobile_black/center/avatar_default.png')
        "
        @click="gotoPersonalCenter"
      />
      <div v-if="userInfo.nickname">
        {{ userInfo.nickname }}
      </div>
      <div>
        {{ userInfo.remark ? userInfo.remark : "该用户什么都没有留下" }}
      </div>
    </div>

    <!-- 底部卡片部分 -->
    <div class="cards w1190 dis-flex">
      <div class="cards_background" @click="gotoCurrentlyOwened">
        <img
          class="icon_img"
          src="@/assets/images/personalCenter/icon-own.png"
          alt=""
        />
        <div class="cards_background_item">
          <div class="tips">当前拥有</div>
          <div class="num">{{ userInfo.already_pay_num }}</div>
        </div>
      </div>
      <div class="cards_background" @click="gotoCollection">
        <img
          class="icon_img"
          src="@/assets/images/personalCenter/icon-collect.png"
          alt=""
        />
        <div class="cards_background_item">
          <div class="tips">我的收藏</div>
          <div class="num">{{ userInfo.collect_num }}</div>
        </div>
      </div>
      <div class="cards_background noMargin" @click="gotoFavorite">
        <img
          class="icon_img"
          src="@/assets/images/personalCenter/icon-like.png"
          alt=""
        />
        <div class="cards_background_item">
          <div class="tips">我的点赞</div>
          <div class="num">{{ userInfo.likes_num }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// store
import { mapState } from "vuex";

export default {
  name: "PersonalHomePage",
  computed: {
    // 获取用户信息
    ...mapState(["userInfo"]),
  },
  methods: {
    // ----- 异步相关的方法 -----

    // ----- 跳转相关的方法 -----
    // 点击当前拥有卡片跳转到对应界面
    gotoCurrentlyOwened() {
      this.$router.push("/personalCurrentlyOwned");
    },
    // 点击我的收藏卡片跳转到对应界面
    gotoCollection() {
      this.$router.push("/personalCollection");
    },
    // 点击我的点赞卡片跳转到对应界面
    gotoFavorite() {
      this.$router.push("/personalFavorite");
    },
    // 点击头像跳转到个人中心界面
    gotoPersonalCenter() {
      this.$router.push("/personalCenter");
    },
    // 返回按钮触发返回到上个界面
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.w1190 {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 20px;
}
.dis-flex {
  display: flex;
}
.f-y-center {
  align-items: center;
}
.f-x-center {
  justify-content: center;
}
.f-x-between {
  justify-content: space-between;
}
#personalHomePage {
  width: 100%;
  height: 903px;
  overflow: auto;

  // 大背景div
  .bigBackground {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: url("../../assets/images/personalCenter/ownbg.png") no-repeat
      center;
    background-size: cover;
    .backbtn {
      width: 104px;
      height: 30px;
      background: url("../../assets/images/personalCenter/btn.png") no-repeat
        center;
      background-size: 100% 100%;
      cursor: pointer;
      gap: 10px;
      .dir_img {
        width: 20px;
        height: 6px;
        display: block;
      }
      .btn_txt {
        font-size: 12px;
        color: #fff;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 12px;
      }
    }
    // -退回按钮div
    .back {
      position: absolute;
      top: 36px;
      left: 360px;

      // 按钮样式
      .backBtn {
        margin: 0;
        padding: 0;
        min-width: 70px;
        height: 40px;
        border: 1px solid #0b81ef;
        border-radius: 5px;
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #0b81ef !important;

        // 向左双箭头样式
        .backBtn_icon {
          line-height: 13px;
          width: 12px;
          height: 13px;
          color: #0b81ef !important;
          transform: translateX(1px);
        }

        // 文字外壳span样式
        .backBtn_span {
          width: 32px;
        }
      }
    }
  }

  // -用户信息div
  .userInfo {
    transform: translateY(-60px);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    font-family: Microsoft YaHei;
    font-weight: 400;

    // 头像
    img {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      cursor: pointer;
    }
    // 用户名
    & :nth-child(2) {
      font-size: 24px;
      color: #fff;
      margin-top: 10px;
    }
    // 留言
    & :nth-child(3) {
      font-size: 14px;
      color: #fff;
      margin-top: 15px;
      margin-bottom: 0;
      max-width: 800px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      // display: -webkit-box;
      // -webkit-line-clamp: 2;
      // -webkit-box-orient: vertical;
      // word-break: break-all;
    }
  }

  // -底部卡片展示div
  .cards {
    width: 100%;
    padding: 0;

    // 每个卡片
    .cards_background {
      position: relative;
      width: 360px;
      height: 120px;
      margin-right: 60px;
      background: url("../../assets/images/personalCenter/public.png") no-repeat
        center;
      background-size: 100% 100%;
      cursor: pointer;

      .icon_img {
        width: 60px;
        height: 60px;
        position: absolute;
        bottom: 0;
        right: 0;
      }
    }
    .noMargin {
      margin-right: 0 !important;
    }
    // 卡片背景

    .cards_background_item {
      padding: 30px 30px;
    }
    .tips {
      font-size: 18px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      line-height: 18px;
    }
    .num {
      font-size: 28px;
      font-family: DINAlternate-Bold, DINAlternate;
      font-weight: bold;
      color: #ffffff;
      line-height: 28px;
      padding-top: 8px;
    }
  }
  @media screen and (max-width: 768px) {
    .wrap {
      display: none;
    }
    .cards_background {
      width: 360px;
      height: 120px;
      margin-right: 20px !important;
    }
    .cards_background .icon_img {
      width: 40px !important;
      height: 40px !important;
    }
  }
}
</style>
